#!/bin/bash
#apt sources.list config

VERSION=$(cat /proc/version | grep -oP "\d{2}\.\d{2}" | sed -n '1p')
if [ $USER != 'root' ]; then
	echo "you must root"
	exit 1;
fi
select_server()
{
 cat> /etc/apt/sources.list <<-EOF
 deb http://mirrors.aliyun.com/ubuntu ${list_dict[${VERSION:0:2}]} main multiverse restricted universe
 deb http://mirrors.aliyun.com/ubuntu ${list_dict[${VERSION:0:2}]}-updates main multiverse restricted universe
 deb http://mirrors.aliyun.com/ubuntu ${list_dict[${VERSION:0:2}]}-security main multiverse restricted universe
 deb http://mirrors.aliyun.com/ubuntu ${list_dict[${VERSION:0:2}]}-proposed main multiverse restricted universe
 deb http://mirrors.aliyun.com/ubuntu ${list_dict[${VERSION:0:2}]}-backports main multiverse restricted universe
EOF
}
#Xenial 16.04
#Bionic 18.04
#Focal 20.04
declare list_dict
list_dict=([16]=xenial ["18"]=bionic [20]=focal)
echo $VERSION
echo ${list_dict[${VERSION:0:2}]}
rm /etc/apt/sources.list &> /dev/null
select_server

